package cn.ibobo.lease.app.configure;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Description: Swagger-UI 配置类 <br/>
 * ClassName: Swagger2Configurer <br/>
 * @version 2.0 2018年2月25日下午4:42:05 <br/>
 */
@Configuration
@EnableSwagger2
public class Swagger2Configurer {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .directModelSubstitute(Byte.class, Integer.class)
            .select()
            .apis(RequestHandlerSelectors.basePackage("cn.ibobo.lease.app"))
            .paths(PathSelectors.any())
            .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
            .title("测试 接口API文档")
            .description("API描述")
            .termsOfServiceUrl("http://localhost:9200/")
            .version("2.0")
            .build();
    }

}
